<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

  <button onclick="testAjax()">testAjax</button>

  <div id="info"></div>

  <script>
      var json = {
          "name": "zhangsan",
          "age": 18,
          "sex": "男"
      };

      var jsonArr = [
          {
              "name": "lisi",
              "age": 18,
              "sex": "男"
          },
        {
            "name": "wangwu",
            "age": 18,
            "sex": "男"
        }
      ]

      console.log(json.name)

      for(var i = 0; i < jsonArr.length; i++){
          console.log(jsonArr[i].name)
      }

      function testAjax() {
        var xmlHttp = new XMLHttpRequest();

        xmlHttp.onreadystatechange = function () {
          if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
            console.log(xmlHttp.responseText)
            document.getElementById("info").innerText = xmlHttp.responseText;
          }
        }

        xmlHttp.open("GET", "info.json");
        xmlHttp.send();
      }
  </script>
</body>
</html>
